home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 20
/
Cream of the Crop 20 (Terry Blount) (1996).iso
/
program
/
n_b_v203.zip
/
MENU-DD.DMO
< prev
next >
Wrap
Text File
|
1996-07-04
|
17KB
|
309 lines
$if 0
┌──────────────────────────╖ PowerBASIC v3.20
┌──┤ DASoft ╟──────────────────────┬──────────────────╖
│ ├──────────────────────────╢ Copyright 1995 │ DATE: 1995-10-01 ╟─╖
│ │ FILE NAME MENU-DD .DMO ║ by ╘════════════════─ ║ ║
│ │ ║ Don Schullian, Jr. ║ ║
│ ╘══════════════════════════╝ ║ ║
│ A license is hereby granted to the holder to use this source code in ║ ║
│ any program, commercial or otherwise, without receiving the express ║ ║
│ permission of the copyright holder and without paying any royalties, ║ ║
│ as long as this code is not distributed in any compilable format. ║ ║
│ IE: source code files, PowerBASIC Unit files, and printed listings ║ ║
╘═╤═════════════════════════════════════════════════════════════════════╝ ║
│ .................................... ║
╘═══════════════════════════════════════════════════════════════════════╝
****************************************************************************
** ** ** ** ** ** ** ** ** GENERAL CHIT-CHAT ** ** ** ** ** ** ** ** ** **
****************************************************************************
This menu system can easily handle a whole program or a simple little pop-up
event/box. Getting all the data DIMed and set just right can be a real pain
but there is just no way to make it much easier and still keep all the power
that is available. The best deal would be to use this file as a test program
for your data and once it's correct transfer it into your program or drop it
all into a file.
Five arrays are used to import data into the menu and they are discussed
below. In addition there are two strings that control the "look" and "feel"
of the menu and provide your program with many possibilities, one of which,
should meet any requirement(s) you need.
By changing the border type, centering, wrap, and auto-open values you can
create your own best set-up. These, and other values, are carried into the
menu by a single string.
TYPE TempTYPE '┌─────────────────────────
BarRow AS BYTE '│ row # for bar items
BarCol AS BYTE '│ starting column of bar items
BarCols AS BYTE '│ # of columns for bar items
Center AS BYTE '│ >0 center bar items on row =0 left justify
BrdrOn AS BYTE '│ border style 0 = none, 1 = underline line, 2 = box
AutoOpen AS BYTE '│ automatically open DD boxes when BAR item is hot
WrapOn AS BYTE '│ wrap cursor selections if > last goto first, etc.
ShdoOn AS BYTE '│ shadow effect for DD boxes SEE: DrawTShadow
Sattr AS BYTE '│ if .ShdoOn what attribute to use
END TYPE '└────────────────────────────────────────────────
DIM tDDsetup AS TempTYPE
M$(0) = tDDsetup + "[ tMain Menup ]"
BYTE #1 Top row for BAR MENU
If BYTE #7 = 2 then this row would be the top of the box
else the actual BAR MENU would reside here
BYTE #2 Left most column for BAR MENU
BYTE #3 Total number of columns for BAR MENU
BYTE #4 Center BarMenu Items?
defines how the BAR MENU items will be printed
IF Center? > 0 then it will appear like PB's menu
IF Center? = 0 then it would look like:
[ File Edit Search Run Compile Options Debug ]
where the items fill in from the left like GUI menus
BYTE #5 Bar Menu border style
defines how many rows are used for the BAR MENU
0 = like PB's menu
1 = a single line "──────────" under the items
this one is good for pop-up boxes, etc.
2 = a full box around the menu ( like old TurboBasic's )
in this case you can also send a "TITLE" that will be printed
top row, center
Which ever you choose the dropdown boxes will have a simple
box around them and the action is automatic so you don't need
to send any further boxing commands except for color attrs.
BYTEs #10-> Title for BarMenu box IF BYTE #6 = 2
BYTE #6 Automatically open 1st DropDown menus?
determines how the first dropdowns will open.
IF = 0 then the user will have to press <ENTER> or <DOWN>
to open the dropdowns
IF > 0 then the first dropdowns will automatically open
when the BAR ITEM is "HOT" and there is a dropdown
to be had. This is PB's style.
This value also affects how <ESC> is handled
BYTE #7 Wrap selection bar?
handles the "UP", "DOWN", "LEFT", "RIGHT" keys and what happens when
the first or last item is currently selected and a further command is
incoming to go "past" the boundary.
If > 0 then it will act like PB's menu
If = 0 then the key-press will be ignored
BYTE #8 Shadow style on DropDown menu boxes:
BYTE #9 Shadow color attribute
SEE: DrawTShadow
NOTE: The menu expects the shadow to be in position #1 (lower right)
so if you use position #2 your 1st DDs will have to start in
column 3 or greater. Positions 3 and 4 will not look good as
the shadow will encroach upon the Bar Menu.
BYTEs #10 and up SEE: BYTE #5
Why call 2 routines for each menu?
MenuDD only gets the environment ready to act, and prints the BAR MENU on
the screen. If the area the BAR MENU will reside over needs to be saved
it will be up to you to capture it. SEE: fTBoxREAD$ This allows your
program to continue on until the user elects to go to the menu, like in
GUI programs. [HELP] [ABOUT] (remember?) Then, when/if the menu is actually
required you simply call fMenuDD$ and instantly you're in business! You can
start at any "ON" item so, if your user presses <ALT>H (for example) you
could automatically jump to item #2 which would be the 1st item under the
first BAR ITEM. fMenuDD$ returns the actual key-press that was used to exit
the menu: <ENTER> or one of your choosing, and the selection made is carried
in a parameter variable SelNo? Upon exiting, all dropdowns are closed but
the BAR MENU is still up and the set-up is unchanged so it can be called
again and again with no other calls to MenuDD. So, for those small programs,
that can be handled by a single menu structure, you would only call MenuDD
only once.
NOTE: <ENTER> is the only key that will automatically exit the menu unless
you provide other keys for this function
<ENTER> is also the only key that will return a selection value >0
<ESC> only closes opened dropdowns and will not exit the menu unless
it has been sent as a "HOT KEY" and then only
1) if Auto-Open is "OFF" and the user is at the BAR MENU
2) if Auto-Open is "ON" and the user is in the 1st DropDown
****************************************************************************
** ** ** ** ** ** ** ** ** ** RULES OF ENGAGEMENT ** ** ** ** ** ** ** ** **
****************************************************************************
The menu is controlled by 4 arrays:
M$() item names VALUES: NULL or not
LEVEL 1 items can not be NULL
All NULL items are replaced with a "├─────┤"
in the pulldown menus
ALL NULL items must be "OFF" ie: O?(x) = 0
H$() help line VALUES: NULL or not
IF UBOUND(H$(1)) < UBOUND(M$(1)) THEN Help is OFF
LINE 25 is stored and then used to Tprint the
help string(s) to that line
MAX Visible length of H$(x) = 78
IF H$(x) = "" AND Help is active LINE 25 is blank
L?() item levels VALUES: the level of the item 1,2,3,etc
1 = bar items
2 = first pull-down und